import api from './request'

export const fileApi = {
    // 上传文件
    uploadFile: (file, ownerId) => {
        const formData = new FormData()
        formData.append('file', file)
        formData.append('ownerId', ownerId.toString())

        // 调试信息
        console.log('FormData内容:')
        for (let [key, value] of formData.entries()) {
            console.log(`${key}:`, value)
        }

        return api.post('/File/upload', formData)
    },

    // 下载文件
    downloadFile: (id) => {
        return api.get(`/File/download/${id}`, {
            responseType: 'blob'
        })
    },

    // 删除文件
    deleteFile: (id) => {
        return api.delete(`/File/${id}`)
    }
} 